#ifndef TUYA_H_
#define TUYA_H_

#include "APP_Main.h"


extern uint8_t Uart_TuYa_TxComplete;


typedef enum
{
    Working_Auto = 0,
    Working_Manual = 1,
    Working_Home = 2,
    Working_Leave = 3
}Working_Model_E;
typedef enum
{
    FaultType_NULL = 0,
    FaultType_Sensor = 1,
    FaultType_Motor = 2,
    FaultType_Heating = 3,
}FaultType_E;

typedef enum
{
    AutoMode_P0 = 0,
    AutoMode_P1 = 1,
    AutoMode_P2 = 2,
    AutoMode_P3 = 3,
    AutoMode_P4 = 4,
    AutoMode_P5 = 5,
    AutoMode_P6 = 6,
}AutoMode_E;
typedef enum
{
    State_Not = 0,
    State_ON = 1,
    State_OFF = 2,
}State_Switch_E;
typedef struct
{
	Working_Model_E Working_Model;
    FaultType_E FaultType;
    AutoMode_E AutoMode;
    char StateOf_Ignite[5]; //点火激活
    char StateOf_CH[5]; //暖气激活
    char StateOf_DHW[5]; //热水激活
    bool Mode_CH; //采暖模式
    State_Switch_E Mode_DHW; //热水模式
    char Temp_CurOutWater_CH[5]; //当前采暖出水温度
    char Temp_CurOutWater_DHW[5]; //当前热水出水温度
    uint16_t TempSetting_CH; //暖气温度设置
    uint16_t TempSetting_DHW; //热水温度设置
    uint16_t TempSetting_Max_CH;
    uint16_t TempSetting_Max_DHW;
    uint16_t TempSetting_Min_CH;
    uint16_t TempSetting_Min_DHW;
    char DeviceRunTime[5]; //设备运行时间

    uint16_t Temp;
    uint16_t TempSetting;
    char OT_Inform[20];
    bool TempCtrl_Switch;
}App_Params_S;
extern App_Params_S App_Params;

typedef enum
{
	WIFI_Config_Smart = 0, //触发 执行配网步骤
	WIFI_Config_Smarting, //配网中...
	WIFI_Config_Disable, //配网无效
}WIFI_Config_E;
extern WIFI_Config_E WIFI_Config;

extern uint8_t WiFi_IsReady;
extern uint8_t StateOf_WIFI;


extern uint8_t OTA_UpdateFlag;


void OTA_Cancel();
void OTA_Start(void);
bool OTA_IsActive(void);

void TuYa_Clock(void);
void TuYa_isReadlyOK();
void TuYa_Init(void);
void TuYa_Main(void);
void TuYa_WiFi_ShineClock(void);
void TuYa_Param_TxClock(void);
void TuYa_WiFi_ConfigNet(void);

#endif
